<template>
  <div class="app-container">
    <el-row :gutter="20">
      <el-col :span="10">
        <div class="grid-content bg-purple">
          <el-card style="border-radius: 10px;">
            <div slot="header" class="clearfix">
              <span>个人信息</span>
            </div>
            <div>
            <ul class="list-group list-group-striped">
              <li class="list-group-item">
                用户名称
                <div class="pull-right">{{ user.userName }}</div>
              </li>
              <li class="list-group-item">
                手机号码
                <div class="pull-right">{{ user.phonenumber }}</div>
              </li>
              <li class="list-group-item">
                用户邮箱
                <div class="pull-right">{{ user.email }}</div>
              </li>
              <li class="list-group-item">
                所属部门
                <div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div>
              </li>
              <li class="list-group-item">
                所属角色
                <div class="pull-right">{{ roleGroup }}</div>
              </li>
              <li class="list-group-item">
                入职日期
                <div class="pull-right">{{ user.createTime }}</div>
              </li>
            </ul>
          </div>
          </el-card>
        </div>
      </el-col>
      <!-- <el-col :span="14">
        <el-card>
          <div id="line" style="width: 800px;height: 400px;"></div>
        </el-card>
      </el-col> -->
    </el-row>
  </div>
</template>


<script>

import { getUserProfile } from "@/api/system/user";
import * as echarts from 'echarts';
const option = {
  xAxis: {
    type: 'category',
    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
  },
  yAxis: {
    type: 'value'
  },
  series: [
    {
      data: [120, 200, 150, 80, 70, 110, 130],
      type: 'bar'
    }
  ]
};

export default {
  name : 'Index',
  data(){
    return {
      user: {},
      roleGroup: {},
      postGroup: {}
    }
  },
  mounted(){
    var chartDom = document.getElementById('line');
    var myChart = echarts.init(chartDom);
    myChart.setOption(option);
  },
  created() {
    this.getUser();
  },
  methods: {
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data;
        this.roleGroup = response.roleGroup;
        this.postGroup = response.postGroup;
      });
    }
  }

}


</script>